package com.charith;

import java.io.File;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Scanner;

public class MinimumScalarProduct {
	
	public static void main(String[] args) throws Exception {
		Scanner in = new Scanner(new File("MinimumScalarProduct//input//A-large-practice.in"));
		PrintWriter out = new PrintWriter(new File("MinimumScalarProduct//C-large-practice.out"));
		int records = in.nextInt();
		System.out.println(records);
		int k=1;
		while(in.hasNext()){
			int arrayLength = in.nextInt();
			int[] first = new int[arrayLength];
			int[] second = new int[arrayLength];
			for(int i=0;i<arrayLength && in.hasNext();i++){
				first[i] = in.nextInt();
			}
			for(int i=0;i<arrayLength && in.hasNext();i++){
				second[i] = in.nextInt();
			}
			
			Arrays.sort(first);
			Arrays.sort(second);
			
			BigDecimal value = new BigDecimal("0");
			for(int j=0;j<arrayLength;j++){
				BigDecimal intermediate = new BigDecimal(first[j]).multiply(new BigDecimal(second[arrayLength-j-1]));
				value = value.add(intermediate);
			}
			
			out.write("Case #"+k+": "+value.longValue());
			out.println();
			k++;
		}
		in.close();
		out.close();
	}
}
